﻿using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using System;
using System.Threading;

namespace Padsurface.Tests
{
    [TestClass]
    public class TestBase
    {
        protected Exception Exception { get; set; }
        protected ManualResetEvent EventTrigger { get; set; }

        [TestInitialize]
        public void Initialize()
        {
            Arrange();
            
            Act();

            if(EventTrigger != null)
                EventTrigger.WaitOne();
        }

        protected virtual void Arrange()
        {

        }

        protected virtual void Act()
        {

        }

        [TestCleanup]
        public virtual void Cleanup()
        {

        }

        protected void ExpectException(Action action)
        {
            try
            {
                action();
            }
            catch (Exception ex)
            {
                Exception = ex;
            }
        }
    }
}
